import {NavigatorRoutePage, NavigatorRouteType} from "plain-micro-application";
import {alertRouteDecodeError, decodeHref, matchNavigatorRoutes} from "plain-micro-application";
import {nav} from "@/micro/nav/nav";

/**
 * 全屏打开页面，private路由，通过url路径获取页面信息，url参数中需要带token
 * @author  韦胜健
 * @date    2021/4/22 14:50
 */
export function getPrivateRoutePage(): NavigatorRoutePage {
    // const href = 'http:/localhost:3021/front-sub-base/private/modules/crm/base/list_of_value/list-of-value.vue?name=hello&age=100&token=crm_e50f8186-8bb6-41e4-89b3-da4f57b61f68'
    const hrefInfo = decodeHref()
    if (!hrefInfo.query.token) {throw alertRouteDecodeError('当前访问地址不正确，地址参数缺少用户令牌字符串！')}
    const urlPath = hrefInfo.matchPrefix(NavigatorRouteType.private)
    return {
        ...matchNavigatorRoutes(urlPath, NavigatorRouteType.private, nav),
        query: hrefInfo.query,
    }
}